package cn.itcast.mybatisplus.service;

import cn.itcast.mybatisplus.entity.User;
import cn.itcast.mybatisplus.mapper.UserMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author piaohailin@163.com
 * @date 2021/4/1
 */
@Service
public class UserMapperService extends ServiceImpl<UserMapper, User> {

    public void selectColumnQueryWrapper() {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("name", "age").like("name", "Jone");
        List<User> users = this.getBaseMapper().selectList(queryWrapper);
        users.forEach(System.out::println);
    }

    public void selectColumnLambdaQueryWrapper() {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.
//                select(User::getName,User::getAge).
                like(User::getName, "Jone");
//        queryWrapper.like(User::getSmsType, 1);

        List<User> users = this.list(queryWrapper);
        users.forEach(System.out::println);
    }
}
